package com.zzl.study.demo.controller;

import com.alibaba.cloud.ai.mcp.router.service.McpRouterService;
import jakarta.annotation.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * MCP Server路由Controller
 *
 * @author: zhangzl
 * @date: 2025/10/20 10:11
 * @version: 1.0
 */
@RestController
public class RouterController {

    @Resource
    private McpRouterService mcpRouterService;

    /**
     * 搜索MCP服务
     * CURL：GET /search?taskDescription={taskDescription}&keywords={keywords}&limit={limit}
     *
     * @param taskDescription 任务描述
     * @param keywords        关键字
     * @param limit           限制
     * @return 搜索结果
     */
    @GetMapping("/search")
    public ResponseEntity<Object> searchServices(@RequestParam String taskDescription,
                                                 @RequestParam(required = false) String keywords,
                                                 @RequestParam(defaultValue = "10", required = false) int limit) {
        return ResponseEntity.ok(this.mcpRouterService.searchMcpServer(taskDescription, keywords, limit));
    }

}
